package cn.qqcn.common.vo;

import lombok.Data;

@Data
public class Result<T> {
    private Integer code;
    private String message;
    private T data; // 更改变量名以更清晰地表达其意图
    private Long count; // 分页查询

    public Result() {
        // 默认构造函数，可以根据需要设置默认值
    }

    public Result(Integer code, String message, T data, Long count) {
        this.code = code;
        this.message = message;
        this.data = data;
        this.count = count;
    }

    public static Result<Object> success() {
        return new Result<>(0, "success", null, null);
    }

    public static Result<Object> success(String message) {
        return new Result<>(0, message, null, null);
    }

    public static Result<Object> success(Object data, Long count) {
        return new Result<>(0, "success",data,count);
    }

    public static Result<Object> fail(String message) {
        return new Result<>(-1, message, null, null);
    }
    public static Result<Object> fail() {
        return new Result<>(-1, "System malfunction", null, null);
    }
}